package com.sxt.disruptor.chap00;

import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;


/**
 * 	消费者同时实现了EventHandler和WorkHandler两个接口。
 * 	如果不需要池化，只需要实现EventHandler类即可。
 * 	如果需要池化，只需要实现WorkHandler类即可。
 * 
 * 	该消费者执行将数值+10的操作
 * @author Administrator
 *
 */
public class C11EventHandler implements EventHandler<TranslatorData>, WorkHandler<TranslatorData>{
	
	//EventHandler的方法
	@Override
	public void onEvent(TranslatorData event, long sequence, boolean endOfBatch) throws Exception {
		// TODO Auto-generated method stub
		long number = event.getNumber();
        number += 10;
        System.out.println(System.currentTimeMillis()+": c1-1 consumer finished.number=" + number);
	}

	//WorkHandler的方法
	@Override
	public void onEvent(TranslatorData event) throws Exception {
		// TODO Auto-generated method stub
		long number = event.getNumber();
        number += 10;
        System.out.println(System.currentTimeMillis()+": c1-1 consumer finished.number=" + number);
	}

}
